package api

import (
	"fmt"
	"log"
	"os"
	"path/filepath"
)

func GetFiles(dir string) ([]string, []string, []map[string]string, error) {
	fs, err := os.ReadDir(dir)
	if err != nil {
		log.Println(err)
		return nil, nil, nil, err
	}
	log.Println(fs)
	files := make([]string, 0)
	filePaths := make([]string, 0)
	filesMapsList := make([]map[string]string, 0)
	filesMap := map[string]string{}
	for _, f := range fs {
		fmt.Println(f.Name())
		files = append(files, f.Name())
		fileAbs, _ := filepath.Abs(f.Name())
		filePaths = append(filePaths, fileAbs)
		filesMap["path"] = fileAbs
		filesMap["name"] = f.Name()
		filesMapsList = append(filesMapsList, filesMap)
		log.Println(filesMapsList)
	}
	log.Println(filesMapsList)
	return files, filePaths, filesMapsList, nil
}
